const authRoute = require('./auth');
const groupsRoute = require('./groups');
const { userRouter, usersRouter } = require('./users');
const categoriesRoute = require('./categories');
const billsRoute = require('./bills');
const noticesRoute = require('./notices');

const { authUser, authSuper } = require('../middleware/auth');
const apiLimiterMiddleware = require('../middleware/api-limiter');

const { getBill } = require('../route-handlers/bills');

const mountRoutes = (app) => {
   app.use('/api/v1/auth', apiLimiterMiddleware, authRoute);

   // 用户
   app.use('/api/v1/user', authUser, userRouter);
   app.use('/api/v1/users', authUser, authSuper,usersRouter);

   // 账单
   app.use('/api/v1/bills', authUser, billsRoute);
   app.use('/api/v1/bill', authUser, getBill);

   app.use('/api/v1/groups', authUser, groupsRoute);
   app.use('/api/v1/categories', authUser, categoriesRoute);
   app.use('/api/v1/notices', authUser, noticesRoute);
};

module.exports = mountRoutes;
